import java.util.*;
public class Test2 {
    public static void main(String[] args) {
        //给一个n  一个长度为n的字符串
        //找出  该字符串种有多少个为“shy”的子序列
        //输入   8   sshhyyau
        //输出  8
        //用动态规划  多状态
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        //输入
        int n = in.nextInt();
        String str = in.next();
        //定义dp数组
        long[] dps = new long[n];
        long[] dpsh = new long[n]; //记录有多少个sh
        long[] dpshy = new long[n];
        dps[0] = str.charAt(0) == 's'? 1: 0;
        dpsh[0] = dpshy[0] = 0;
        for(int i = 1;i < n; i++) {
            if(str.charAt(i) == 's') {
                dps[i] = dps[i-1] + 1;
            }else{
                dps[i] = dps[i-1];
            }
        }

        for(int i = 1; i < n; i++) {
            if(str.charAt(i) == 'h') {
                dpsh[i] = dps[i-1] + dpsh[i-1];
            }else{
                dpsh[i] = dpsh[i-1];
            }
        }

        for(int i = 1; i < n; i++) {
            if(str.charAt(i) == 'y') {
                dpshy[i] = dpsh[i-1] + dpshy[i-1];
            }else{
                dpshy[i] = dpshy[i-1];
            }
        }
        System.out.println(dpshy[n-1]);
    }
    }

